package com.rem.designPattern.prototype原型.deepclone2;

/**
 * 深拷贝-通过对象序列化实现深拷贝
 *
 * @author Rem
 * @date 2022-11-15
 */
public class Client {

    public static void main(String[] args) throws CloneNotSupportedException {
        Sheep sheep = new Sheep("tom", 1);
        Shepherd shepherd = new Shepherd("卓玛", sheep);

        Shepherd shepherd1 = shepherd.deepClone();
        Shepherd shepherd2 = shepherd.deepClone();
        Shepherd shepherd3 = shepherd.deepClone();

        System.out.println(shepherd1.getName() + " stu.hash " + shepherd1.getStudent().hashCode());
        System.out.println(shepherd2.getName() + " stu.hash " + shepherd2.getStudent().hashCode());
        System.out.println(shepherd3.getName() + " stu.hash " + shepherd3.getStudent().hashCode());
    }
}